package org.yefei.homeworkday26;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;

public class ComThread extends Thread {
	Company com;

	public ComThread(Company com) {
		this.com = com;
	}

	@Override
	public void run() {
		while (true) {
			ObjectOutputStream o = null;
			OutputStream oo = null;
			try {
				sleep(20000);
				oo = new FileOutputStream("F:\\叶飞io测试\\IOhomework测试\\info.txt");
				o = new ObjectOutputStream(oo);
				o.writeObject(com);
				System.out.println("正在写入请等待。。。");
			} catch (Exception e) {
				e.printStackTrace();
			}
			if (o != null)
				try {
					o.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
		}
	}
}
